package com.situ.mall.generic;

import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;

public class AuthorDemo {

    @Test
    //@Author(name = "张三", age = 19, value = "北京")
    @Author("北京")
    public void save() throws NoSuchMethodException {
        // 获得注解信息：name/age/value

        // 1.先获取代表方法的Method类型
        Class<AuthorDemo> clazz = AuthorDemo.class;
        Method method = clazz.getMethod("save");
        // 2、获取方法上的注解
        Author author = method.getAnnotation(Author.class);
        System.out.println(author.name());
        System.out.println(author.age());
        System.out.println(author.value());
    }
}
